<?php
/**
 * Plugin: commentTags
 * Author: Garry Nutting
 * Version: 1.1
 * For: MODx 0.9.5+
 * 
 * Attach to: OnParseDocument, OnWebpagePrerender
 */

// set the tag nomenclature
$commentOpenTag = '[comment]';
$commentCloseTag = '[/comment]';

// escape special regex characters
$commentOpenTag = preg_quote($commentOpenTag,'/');
$commentCloseTag = preg_quote($commentCloseTag,'/');

// remove comments
$output = &$modx->documentOutput;
$e = &$modx->Event;

switch ($e->name) {
	case 'OnParseDocument':
	case 'OnWebPagePrerender':
		$output = preg_replace('/('.$commentOpenTag.'.*?'.$commentCloseTag.')/ims','',$output);
	break;
	default:
	return;
	break;
}
?>